﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using Quartz.Impl;

namespace wrsm.client {

    /// <summary>
    /// Scheduler Manager - Manages All Schedules, Jobs, Triggers etc
    /// </summary>
    internal class SchedulerManager {

        /// <summary>
        /// Scheduler Factory
        /// </summary>
        private ISchedulerFactory _schedulerFactory;

        /// <summary>
        /// Our actual scheduler
        /// </summary>
        private IScheduler _scheduler;

        /// <summary>
        /// Initialize Scheduler Manager
        /// </summary>
        public SchedulerManager() {
            _schedulerFactory = new StdSchedulerFactory();
            _scheduler = _schedulerFactory.GetScheduler();
            _scheduler.Start();
        }

        /// <summary>
        /// Starts the auto update process
        /// </summary>
        public void Start() {
            if (_scheduler.InStandbyMode)
                _scheduler.Start();
        }

        /// <summary>
        /// Suspend the auto update process
        /// </summary>
        public void Stop() {
            if (!_scheduler.InStandbyMode)
                _scheduler.Standby();
        }

        /// <summary>
        /// Shuts Down the scheduler
        /// </summary>
        public void Shutdown() {
            _scheduler.Shutdown();
        }

    }
}
